package com.caiyigo.struts.daoImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.caiyigo.struts.dao.IDepartmentDao;
import com.caiyigo.struts.model.Department;


public class DepartmentDaoImpl implements IDepartmentDao {  
    private static List<Department> departments;  
    private static Map<Integer, Department> departmentsMap;  
    static {  
        departments = new ArrayList<Department>();  
        departments.add(new Department(new Integer(100), "研发部"));  
        departments.add(new Department(new Integer(200), "人事部"));  
        departments.add(new Department(new Integer(300), "销售部"));  
        departmentsMap = new HashMap<Integer, Department>();  
        Iterator<Department> iter = departments.iterator();  
        while (iter.hasNext()) {  
            Department dept = (Department) iter.next();  
            departmentsMap.put(dept.getDepartmentId(), dept);  
        }  
    }  
  
    public List<Department> getAllDepartments() {  
        return departments;  
    }  
  
    public Map<Integer, Department> getDepartmentsMap() {  
        return departmentsMap;  
    }  
} 